//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at  http://www.nopCommerce.com/License.aspx. 
// 
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
// See the License for the specific language governing rights and limitations under the License.
// 
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
// 
// Contributor(s): _______. 
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.Text;
using System.Configuration.Provider;
using NopSolutions.NopCommerce.DataAccess;

namespace NopSolutions.NopCommerce.DataAccess.Promo.Discounts
{
    /// <summary>
    /// A collection of objects that inherit the DBDiscountProvider abstract class.
    /// </summary>
    public sealed class DBDiscountProviderCollection : ProviderCollection
    {
        /// <summary>
        /// Adds a provider to the collection.
        /// </summary>
        /// <param name="provider">The provider to be added.</param>
        public override void Add(ProviderBase provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (!(provider is DBDiscountProvider))
            {
                throw new ArgumentException(string.Format("Provider must implement {0} type", new object[] { typeof(DBDiscountProvider).ToString() }), "provider");
            }
            base.Add(provider);
        }

        /// <summary>
        /// Copies the contents of the collection to the given array starting at the specified index.
        /// </summary>
        /// <param name="array">The array to copy the elements of the collection to.</param>
        /// <param name="index">The index of the collection item at which to start the copying process.</param>
        public void CopyTo(DBDiscountProvider[] array, int index)
        {
            base.CopyTo(array, index);
        }

        /// <summary>
        /// Gets the provider with the specified name.
        /// </summary>
        /// <param name="name">The key by which the provider is identified.</param>
        /// <returns>The provider with the specified name.</returns>
        public DBDiscountProvider this[string name]
        {
            get
            {
                return (DBDiscountProvider)base[name];
            }
        }
    }
}